]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
recorder: save recorded video as recent item
authorRay Strode <rstrode@redhat.com>
Thu, 25 Oct 2012 21:26:17 +0000 (17:26 -0400)
committerRay Strode <rstrode@redhat.com>
Fri, 26 Oct 2012 17:29:30 +0000 (13:29 -0400)
Often the first thing a user wants to do after making a recording
is post it somewhere.

This commit adds the video to recently used items, so that it shows
up prominently in open file choosers.

https://bugzilla.gnome.org/show_bug.cgi?id=680647

configure.ac
src/shell-recorder.c
src/test-recorder.c

index 41fc672f6126d92f7f259fad8ea478894d349d87..9eb3a0278e17739256c42ca72ea08b6674e8c018 100644 (file)
@@ -52,7 +52,7 @@ AC_MSG_CHECKING([for GStreamer (needed for recording functionality)])
 if $PKG_CONFIG --exists gstreamer-1.0 '>=' $GSTREAMER_MIN_VERSION ; then
    AC_MSG_RESULT(yes)
    build_recorder=true
-   recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11"
+   recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11 gtk+-3.0"
    PKG_CHECK_MODULES(TEST_SHELL_RECORDER, $recorder_modules clutter-1.0 xfixes gl)
 else
    AC_MSG_RESULT(no)
index dbcd0ce78a8279a5a5832b381b9a9919d791686b..6a11343a42a7679450209f7f9f6d3c1c86dad7f2 100644 (file)
@@ -11,6 +11,8 @@
 #define GST_USE_UNSTABLE_API
 #include <gst/gst.h>
 
+#include <gtk/gtk.h>
+
 #include "shell-recorder-src.h"
 #include "shell-recorder.h"
 #include "shell-screen-grabber.h"
@@ -90,6 +92,7 @@ struct _RecorderPipeline
   GstElement *pipeline;
   GstElement *src;
   int outfile;
+  char *filename;
 };
 
 static void recorder_set_stage    (ShellRecorder *recorder,
@@ -1137,7 +1140,8 @@ get_absolute_path (char *maybe_relative)
  * be opened.
  */
 static int
-recorder_open_outfile (ShellRecorder *recorder)
+recorder_open_outfile (ShellRecorder  *recorder,
+                       char          **outfilename)
 {
   const char *pattern;
   int flags;
@@ -1218,8 +1222,12 @@ recorder_open_outfile (ShellRecorder *recorder)
         {
           g_printerr ("Recording to %s\n", path);
 
+          if (outfilename != NULL)
+            *outfilename = path;
+          else
+            g_free (path);
           g_string_free (filename, TRUE);
-          g_free (path);
+
           goto out;
         }
 
@@ -1257,7 +1265,8 @@ recorder_pipeline_add_sink (RecorderPipeline *pipeline)
       return TRUE;
     }
 
-  pipeline->outfile = recorder_open_outfile (pipeline->recorder);
+  pipeline->outfile = recorder_open_outfile (pipeline->recorder,
+                                             &pipeline->filename);
   if (pipeline->outfile == -1)
     goto out;
 
@@ -1332,6 +1341,8 @@ recorder_pipeline_free (RecorderPipeline *pipeline)
   if (pipeline->outfile != -1)
     close (pipeline->outfile);
 
+  g_free (pipeline->filename);
+
   g_clear_object (&pipeline->recorder);
 
   g_free (pipeline);
@@ -1383,6 +1394,10 @@ recorder_pipeline_closed (RecorderPipeline *pipeline)
 
   if (pipeline->recorder)
     {
+      GtkRecentManager *recent_manager;
+      GFile *file;
+      char *uri;
+
       ShellRecorder *recorder = pipeline->recorder;
       if (pipeline == recorder->current_pipeline)
         {
@@ -1391,6 +1406,15 @@ recorder_pipeline_closed (RecorderPipeline *pipeline)
           shell_recorder_close (recorder);
         }
 
+      recent_manager = gtk_recent_manager_get_default ();
+
+      file = g_file_new_for_path (pipeline->filename);
+      uri = g_file_get_uri (file);
+      gtk_recent_manager_add_item (recent_manager,
+                                   uri);
+      g_free (uri);
+      g_object_unref (file);
+
       recorder->pipelines = g_slist_remove (recorder->pipelines, pipeline);
     }
 
index caba5dcb7e07e828c8cea3fc6df51e659534014c..ec2b05e9e5f01feb3a184a56bfaf97d1c60430aa 100644 (file)
@@ -3,6 +3,7 @@
 #define GST_USE_UNSTABLE_API
 #include "shell-recorder.h"
 #include <clutter/clutter.h>
+#include <gtk/gtk.h>
 #include <gst/gst.h>
 
 /* Very simple test of the ShellRecorder class; shows some text strings
@@ -57,6 +58,7 @@ int main (int argc, char **argv)
   ClutterAnimation *animation;
   ClutterColor red, green, blue;
 
+  gtk_init (&argc, &argv);
   gst_init (&argc, &argv);
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;